const express = require('express');
const router = express.Router();

router.get('/forCurrentUser', (req, res) => {
    const content = [];
    for(let i = 0; i < 100; i++) content.push({
        id: `id${i}`,
        code: `513200${i}`,
        name: `name${i}`,
        shortCode: `123${i}`,
        shortName: `shortName${i}`,
        country: '中国',
        province: '重庆市',
        city: '重庆',
        contactNumber: '12580',
        address: '东和春天',
        rowVersion: 'string',
        options: [
            'update'
        ]
    });

    res.json({
        message: 'ok',
        payload: {
            content,
            totalElements: 40,
        }
    });
});

router.get('/:id', (req, res) => {
    res.json({
        message: 'ok',
        payload: {
            id: '001',
            code: '513200001',
            name: 'dealerName001',
            shortCode: '123001',
            shortName: 'shortName001',
            kind: 20,
            area: '东亚大区',
            country: '中国',
            province: '重庆市',
            city: '重庆',
            contactNumber: '12580',
            fax: '12354532',
            address: '东和春天',
            zipCode: '404000',
            options: [
                'update'
            ],
            rowVersion: 'string',
            dealerServiceInformations: [
                {
                    id: 'id001',
                    brandId: 'de872f12',
                    brandCode: 'code001',
                    brandName: 'brandName001',
                    tradeMethodId: '26e30b7b',
                    tradeMethodCode: 'tradeMethodCode001',
                    tradeMethodName: 'tradeMethodName001',
                    priceClause: 1,
                    currency: 1,
                    cbuIntervalDate: 7,
                    kdIntervalDate: 8,
                    exAuthorizatedLimit: 256,
                    price: 1235,
                    priceRate: 0.2,
                    mgmtFeeRate: 0.5,
                    guaranteeDate: 5,
                    guaranteeMileage: 10,
                    beginClaimSettlementDate: 7,
                    endClaimSettlementDate: 8,
                    isNeedApproved: false,
                    submitTimeLimit: null,
                    claimPITitle: 'claimPITitle1'
                },
                {
                    id: 'id002',
                    brandId: '392e69de',
                    brandCode: 'code002',
                    brandName: 'brandName002',
                    tradeMethodId: '52a1ad34',
                    tradeMethodCode: 'tradeMethodCode002',
                    tradeMethodName: 'tradeMethodName002',
                    priceClause: 1,
                    currency: 1,
                    cbuIntervalDate: 7,
                    kdIntervalDate: 8,
                    exAuthorizatedLimit: 256,
                    price: 1235,
                    priceRate: 0.2,
                    mgmtFeeRate: 0.5,
                    guaranteeDate: 5,
                    guaranteeMileage: 10,
                    beginClaimSettlementDate: 7,
                    endClaimSettlementDate: 8,
                    isNeedApproved: true,
                    submitTimeLimit: null,
                    claimPITitle: 'claimPITitle2'
                },
            ],
            dealerPersonnels: [
                {
                    id: '001',
                    userName: 'userName001',
                    name: 'name001'
                },
                {
                    id: '002',
                    userName: 'userName002',
                    name: 'name002'
                },
            ],
            partPriceCoefficientDetail: [
                {
                    id: '001',
                    brandId: 'brandId1',
                    brandCode: 'brandCode1',
                    brandName: 'brandName1',
                    year: 2019,
                    month: 12,
                    priceRate: 0.20,
                    isNow: false
                },
                {
                    id: '002',
                    brandId: 'brandId2',
                    brandCode: 'brandCode2',
                    brandName: 'brandName2',
                    year: 2020,
                    month: 11,
                    priceRate: 0.50,
                    isNow: true
                },
                {
                    id: '001',
                    brandId: 'brandId1',
                    brandCode: 'brandCode1',
                    brandName: 'brandName1',
                    year: 2019,
                    month: 10,
                    priceRate: 0.20,
                    isNow: false
                },
            ],
            specialPartPriceCoefficient: [
                {
                    id: '1',
                    brandId: 'brandId1',
                    brandCode: 'brandCode1',
                    brandName: 'brandName1',
                    partId: 'partId1',
                    partCode: 'partCode1',
                    partName: 'partName',
                    priceRate: 0.20,
                    startTime: '2019-12-05T06:01:28.937Z',
                    endTime: '2019-12-05T06:01:28.937Z'
                },
                {
                    id: '2',
                    brandId: 'brandId2',
                    brandCode: 'brandCode2',
                    brandName: 'brandName2',
                    partId: 'partId2',
                    partCode: 'partCode2',
                    partName: 'partName2',
                    priceRate: 0.30,
                    startTime: '2019-12-05T06:01:28.937Z',
                    endTime: '2019-12-05T06:01:28.937Z'
                }
            ]
        },
        totalElements: 40,
    });
});

router.put('/:id/', (req, res) => {
    res.json({
        message: '编辑成功'
    });
});

router.get('/export/forCurrentUser', (req, res) => {
    res.json({
        message: '导出成功',
        payload: 'Mock导出'
    });
});

router.post('/import', (req, res) => {
    res.json({
        message: 'success',
        payload: '导入成功'
    });
});
module.exports = router;
